package com.inspur.ehcache.controller;

import com.inspur.ehcache.entity.User;
import com.inspur.ehcache.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@EnableCaching
@RestController
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/getUserById/{id}")
    public Object getUserById(@PathVariable("id")Integer id){
        return userService.selectUserById(id);
    }

    @RequestMapping("/updateUserById")
    public Object updateUserById(User user){
        return userService.updateUserById(user);
    }

    @RequestMapping("/deleteUserById/{id}")
    public void deleteUserById(@PathVariable("id")Integer id){
        userService.deleteUserById(id);
    }
}
